package com.alittle.support.support.widget;

import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.widget.ImageView;

import dev.xesam.chelaile.support.R;


/**
 * Created by xe on 15-6-18.
 * 圆形色彩按钮
 */
public class TintCircleImageView extends ImageView {

    public TintCircleImageView(Context context) {
        this(context, null);
    }

    public TintCircleImageView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public TintCircleImageView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        setClickable(true);
        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.YGKJ, defStyleAttr, 0);
        ColorStateList mBackgroundTint = a.getColorStateList(R.styleable.YGKJ_backgroundTint);
        a.recycle();

        if (mBackgroundTint != null) {
            setTintCircleColorList(mBackgroundTint);
        }
    }

    public void setTintCircleColorList(ColorStateList colorStateList) {
        TintColorDrawable.setTintCircleColorList(this, colorStateList);
    }

    public void setTintCircleColorId(int colorResId) {
        TintColorDrawable.setTintCircleColorList(this, getResources().getColorStateList(colorResId));
    }

    public void setTintCircleColor(int color) {
        TintColorDrawable.setTintCircleColor(this, color);
    }
}
